package com.globallogic.drawtoken;

import java.util.Iterator;
import java.util.List;

import com.globallogic.draw.DrawContainer;
import com.globallogic.draw.Drawable;
import com.globallogic.draw.Drawer;
import com.globallogic.draw.Rectangle;
import com.globallogic.token.TokenHandler;
import com.globallogic.token.TokenProcessor;

public class TokenHandlerDrawRectangle implements TokenHandler {

	@Override
	public void execute(TokenProcessor tokenProcessor, List<String> params) {
		
		Iterator<Drawable> iterator = DrawContainer.getInstance().iterator();
		Drawable drawObject;
        Drawer<Rectangle> drawer = new Drawer<Rectangle>();
		
    	while (iterator.hasNext()) {
    			
    		drawObject = iterator.next();

    		if (drawObject instanceof Rectangle) {
    			
    			drawer.add((Rectangle) drawObject);
    			
    		}
    			
    	}
		
    	drawer.draw();
			
	}
	
}
